package com.mongo.data.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

public enum JobStatus {
    INIT("Init","任务开始"),
//    RUNNING("Running", "任务运行中"),
    RUNNING("RUNNING", "任务运行中"),
    SUCCEEDED("Succeeded", "任务成功"),
    FAILED("Failed", "任务失败"),

    ERROR("Error", "任务错误"),
    UNKNOWN("Unknown","未知状态");

    @Getter
    private String desc;

    @Getter
    private String name;
    JobStatus(String name, String desc) {
        this.desc = desc;
        this.name = name;
    }

    public String getName()
    {
        return name;
    }

    private static Map<String, JobStatus> statusEnumMap = new HashMap<>();

    static {
        for (JobStatus jobStatus : JobStatus.values()) {
            statusEnumMap.put(jobStatus.name, jobStatus);
        }
    }

    public static JobStatus toEnum(String name) {
        return statusEnumMap.get(name);
    }
}
